﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Design_Pattners.Composite;

namespace Module_Basic_Entities
{
    /// <summary>
    /// Represents a 2D map from the Mappy Tool.
    /// </summary>
    public class Map2D : Map
    {
        internal SpriteBatch SpriteBatch { get; set; }
        internal Vector2 WorldPosition { get; set; }
        internal Color Color { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Draw(float gameTime)
        {
            foreach (MapComponent c in this._children)
            {
                if (c is Layer2D)
                    ((Layer2D)c).Draw(gameTime, this.SpriteBatch, this.WorldPosition, this.Color);
                else if (c is Map)
                {
                    ((Map2D)c).SpriteBatch = SpriteBatch;
                    ((Map2D)c).WorldPosition = WorldPosition;
                    ((Map2D)c).Color = Color;
                }
            }

            base.Draw(gameTime);
        }
    }
}
